<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html 
     PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
  <title>Class: Spec::Story::Runner::StoryParser</title>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  <meta http-equiv="Content-Script-Type" content="text/javascript" />
  <link rel="stylesheet" href="../../../.././rdoc-style.css" type="text/css" media="screen" />
  <script type="text/javascript">
  // <![CDATA[

  function popupCode( url ) {
    window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
  }

  function toggleCode( id ) {
    if ( document.getElementById )
      elem = document.getElementById( id );
    else if ( document.all )
      elem = eval( "document.all." + id );
    else
      return false;

    elemStyle = elem.style;
    
    if ( elemStyle.display != "block" ) {
      elemStyle.display = "block"
    } else {
      elemStyle.display = "none"
    }

    return true;
  }
  
  // Make codeblocks hidden by default
  document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
  
  // ]]>
  </script>

</head>
<body>



    <div id="classHeader">
        <table class="header-table">
        <tr class="top-aligned-row">
          <td><strong>Class</strong></td>
          <td class="class-name-in-header">Spec::Story::Runner::StoryParser</td>
        </tr>
        <tr class="top-aligned-row">
            <td><strong>In:</strong></td>
            <td>
                <a href="../../../../files/vendor/plugins/rspec/lib/spec/story/runner/story_parser_rb.html">
                vendor/plugins/rspec/lib/spec/story/runner/story_parser.rb
                </a>
        <br />
            </td>
        </tr>

        <tr class="top-aligned-row">
            <td><strong>Parent:</strong></td>
            <td>
                <a href="../../../Object.html">
                Object
               </a>
            </td>
        </tr>
        </table>
    </div>
  <!-- banner header -->

  <div id="bodyContent">



  <div id="contextContent">



   </div>

    <div id="method-list">
      <h3 class="section-bar">Methods</h3>

      <div class="name-list">
      <a href="#M000032">add_story_line</a>&nbsp;&nbsp;
      <a href="#M000039">add_to_last</a>&nbsp;&nbsp;
      <a href="#M000035">create_given</a>&nbsp;&nbsp;
      <a href="#M000036">create_given_scenario</a>&nbsp;&nbsp;
      <a href="#M000034">create_scenario</a>&nbsp;&nbsp;
      <a href="#M000033">create_story</a>&nbsp;&nbsp;
      <a href="#M000038">create_then</a>&nbsp;&nbsp;
      <a href="#M000037">create_when</a>&nbsp;&nbsp;
      <a href="#M000031">init_story</a>&nbsp;&nbsp;
      <a href="#M000028">new</a>&nbsp;&nbsp;
      <a href="#M000029">parse</a>&nbsp;&nbsp;
      <a href="#M000030">process_line</a>&nbsp;&nbsp;
      <a href="#M000041">states</a>&nbsp;&nbsp;
      <a href="#M000040">transition_to</a>&nbsp;&nbsp;
      </div>
    </div>

  </div>


    <!-- if includes -->

    <div id="section">

    <div id="class-list">
      <h3 class="section-bar">Classes and Modules</h3>

      Class <a href="StoryParser/GivenState.html" class="link">Spec::Story::Runner::StoryParser::GivenState</a><br />
Class <a href="StoryParser/ScenarioState.html" class="link">Spec::Story::Runner::StoryParser::ScenarioState</a><br />
Class <a href="StoryParser/StartingState.html" class="link">Spec::Story::Runner::StoryParser::StartingState</a><br />
Class <a href="StoryParser/State.html" class="link">Spec::Story::Runner::StoryParser::State</a><br />
Class <a href="StoryParser/StoryState.html" class="link">Spec::Story::Runner::StoryParser::StoryState</a><br />
Class <a href="StoryParser/ThenState.html" class="link">Spec::Story::Runner::StoryParser::ThenState</a><br />
Class <a href="StoryParser/WhenState.html" class="link">Spec::Story::Runner::StoryParser::WhenState</a><br />

    </div>




      


    <!-- if method_list -->
    <div id="methods">
      <h3 class="section-bar">Public Class methods</h3>

      <div id="method-M000028" class="method-detail">
        <a name="M000028"></a>

        <div class="method-heading">
          <a href="#M000028" class="method-signature">
          <span class="method-name">new</span><span class="method-args">(story_mediator)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000028-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000028-source">
<pre>
    <span class="ruby-comment cmt"># File vendor/plugins/rspec/lib/spec/story/runner/story_parser.rb, line 12</span>
12:         <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">initialize</span>(<span class="ruby-identifier">story_mediator</span>)
13:           <span class="ruby-ivar">@story_mediator</span> = <span class="ruby-identifier">story_mediator</span>
14:           <span class="ruby-ivar">@current_story_lines</span> = []
15:           <span class="ruby-identifier">transition_to</span>(<span class="ruby-identifier">:starting_state</span>)
16:         <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <h3 class="section-bar">Public Instance methods</h3>

      <div id="method-M000032" class="method-detail">
        <a name="M000032"></a>

        <div class="method-heading">
          <a href="#M000032" class="method-signature">
          <span class="method-name">add_story_line</span><span class="method-args">(line)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000032-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000032-source">
<pre>
    <span class="ruby-comment cmt"># File vendor/plugins/rspec/lib/spec/story/runner/story_parser.rb, line 46</span>
46:         <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">add_story_line</span>(<span class="ruby-identifier">line</span>)
47:           <span class="ruby-ivar">@current_story_lines</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">line</span>
48:         <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000039" class="method-detail">
        <a name="M000039"></a>

        <div class="method-heading">
          <a href="#M000039" class="method-signature">
          <span class="method-name">add_to_last</span><span class="method-args">(line)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000039-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000039-source">
<pre>
    <span class="ruby-comment cmt"># File vendor/plugins/rspec/lib/spec/story/runner/story_parser.rb, line 77</span>
77:         <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">add_to_last</span>(<span class="ruby-identifier">line</span>)
78:           <span class="ruby-ivar">@story_mediator</span>.<span class="ruby-identifier">add_to_last</span>(<span class="ruby-node">&quot;\n#{line}&quot;</span>)
79:         <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000035" class="method-detail">
        <a name="M000035"></a>

        <div class="method-heading">
          <a href="#M000035" class="method-signature">
          <span class="method-name">create_given</span><span class="method-args">(name)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000035-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000035-source">
<pre>
    <span class="ruby-comment cmt"># File vendor/plugins/rspec/lib/spec/story/runner/story_parser.rb, line 61</span>
61:         <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">create_given</span>(<span class="ruby-identifier">name</span>)
62:           <span class="ruby-ivar">@story_mediator</span>.<span class="ruby-identifier">create_given</span>(<span class="ruby-identifier">name</span>)
63:         <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000036" class="method-detail">
        <a name="M000036"></a>

        <div class="method-heading">
          <a href="#M000036" class="method-signature">
          <span class="method-name">create_given_scenario</span><span class="method-args">(name)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000036-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000036-source">
<pre>
    <span class="ruby-comment cmt"># File vendor/plugins/rspec/lib/spec/story/runner/story_parser.rb, line 65</span>
65:         <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">create_given_scenario</span>(<span class="ruby-identifier">name</span>)
66:           <span class="ruby-ivar">@story_mediator</span>.<span class="ruby-identifier">create_given_scenario</span>(<span class="ruby-identifier">name</span>)
67:         <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000034" class="method-detail">
        <a name="M000034"></a>

        <div class="method-heading">
          <a href="#M000034" class="method-signature">
          <span class="method-name">create_scenario</span><span class="method-args">(title)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000034-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000034-source">
<pre>
    <span class="ruby-comment cmt"># File vendor/plugins/rspec/lib/spec/story/runner/story_parser.rb, line 57</span>
57:         <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">create_scenario</span>(<span class="ruby-identifier">title</span>)
58:           <span class="ruby-ivar">@story_mediator</span>.<span class="ruby-identifier">create_scenario</span>(<span class="ruby-identifier">title</span>.<span class="ruby-identifier">gsub</span>(<span class="ruby-value str">&quot;Scenario: &quot;</span>,<span class="ruby-value str">&quot;&quot;</span>))
59:         <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000033" class="method-detail">
        <a name="M000033"></a>

        <div class="method-heading">
          <a href="#M000033" class="method-signature">
          <span class="method-name">create_story</span><span class="method-args">()</span>
          </a>
        </div>
      
        <div class="method-description">
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000033-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000033-source">
<pre>
    <span class="ruby-comment cmt"># File vendor/plugins/rspec/lib/spec/story/runner/story_parser.rb, line 50</span>
50:         <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">create_story</span>()
51:           <span class="ruby-keyword kw">unless</span> <span class="ruby-ivar">@current_story_lines</span>.<span class="ruby-identifier">empty?</span>
52:             <span class="ruby-ivar">@story_mediator</span>.<span class="ruby-identifier">create_story</span>(<span class="ruby-ivar">@current_story_lines</span>[<span class="ruby-value">0</span>].<span class="ruby-identifier">gsub</span>(<span class="ruby-value str">&quot;Story: &quot;</span>,<span class="ruby-value str">&quot;&quot;</span>), <span class="ruby-ivar">@current_story_lines</span>[<span class="ruby-value">1</span><span class="ruby-operator">..</span><span class="ruby-value">-1</span>].<span class="ruby-identifier">join</span>(<span class="ruby-value str">&quot;\n&quot;</span>))
53:             <span class="ruby-ivar">@current_story_lines</span>.<span class="ruby-identifier">clear</span>
54:           <span class="ruby-keyword kw">end</span>
55:         <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000038" class="method-detail">
        <a name="M000038"></a>

        <div class="method-heading">
          <a href="#M000038" class="method-signature">
          <span class="method-name">create_then</span><span class="method-args">(name)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000038-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000038-source">
<pre>
    <span class="ruby-comment cmt"># File vendor/plugins/rspec/lib/spec/story/runner/story_parser.rb, line 73</span>
73:         <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">create_then</span>(<span class="ruby-identifier">name</span>)
74:           <span class="ruby-ivar">@story_mediator</span>.<span class="ruby-identifier">create_then</span>(<span class="ruby-identifier">name</span>)
75:         <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000037" class="method-detail">
        <a name="M000037"></a>

        <div class="method-heading">
          <a href="#M000037" class="method-signature">
          <span class="method-name">create_when</span><span class="method-args">(name)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000037-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000037-source">
<pre>
    <span class="ruby-comment cmt"># File vendor/plugins/rspec/lib/spec/story/runner/story_parser.rb, line 69</span>
69:         <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">create_when</span>(<span class="ruby-identifier">name</span>)
70:           <span class="ruby-ivar">@story_mediator</span>.<span class="ruby-identifier">create_when</span>(<span class="ruby-identifier">name</span>)
71:         <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000031" class="method-detail">
        <a name="M000031"></a>

        <div class="method-heading">
          <a href="#M000031" class="method-signature">
          <span class="method-name">init_story</span><span class="method-args">(title)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000031-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000031-source">
<pre>
    <span class="ruby-comment cmt"># File vendor/plugins/rspec/lib/spec/story/runner/story_parser.rb, line 41</span>
41:         <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">init_story</span>(<span class="ruby-identifier">title</span>)
42:           <span class="ruby-ivar">@current_story_lines</span>.<span class="ruby-identifier">clear</span>
43:           <span class="ruby-identifier">add_story_line</span>(<span class="ruby-identifier">title</span>)
44:         <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000029" class="method-detail">
        <a name="M000029"></a>

        <div class="method-heading">
          <a href="#M000029" class="method-signature">
          <span class="method-name">parse</span><span class="method-args">(lines)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000029-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000029-source">
<pre>
    <span class="ruby-comment cmt"># File vendor/plugins/rspec/lib/spec/story/runner/story_parser.rb, line 18</span>
18:         <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">parse</span>(<span class="ruby-identifier">lines</span>)
19:           <span class="ruby-identifier">lines</span>.<span class="ruby-identifier">reject!</span> {<span class="ruby-operator">|</span><span class="ruby-identifier">line</span><span class="ruby-operator">|</span> <span class="ruby-identifier">line</span> <span class="ruby-operator">==</span> <span class="ruby-value str">&quot;&quot;</span>}
20:           <span class="ruby-keyword kw">until</span> <span class="ruby-identifier">lines</span>.<span class="ruby-identifier">empty?</span>
21:             <span class="ruby-identifier">process_line</span>(<span class="ruby-identifier">lines</span>.<span class="ruby-identifier">shift</span>)
22:           <span class="ruby-keyword kw">end</span>
23:           <span class="ruby-ivar">@state</span>.<span class="ruby-identifier">eof</span>
24:         <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000030" class="method-detail">
        <a name="M000030"></a>

        <div class="method-heading">
          <a href="#M000030" class="method-signature">
          <span class="method-name">process_line</span><span class="method-args">(line)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000030-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000030-source">
<pre>
    <span class="ruby-comment cmt"># File vendor/plugins/rspec/lib/spec/story/runner/story_parser.rb, line 26</span>
26:         <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">process_line</span>(<span class="ruby-identifier">line</span>)
27:           <span class="ruby-identifier">line</span>.<span class="ruby-identifier">strip!</span>
28:           <span class="ruby-keyword kw">case</span> <span class="ruby-identifier">line</span>
29:           <span class="ruby-keyword kw">when</span> <span class="ruby-regexp re">/^#/</span>                 <span class="ruby-keyword kw">then</span> <span class="ruby-ivar">@state</span>.<span class="ruby-identifier">comment</span>(<span class="ruby-identifier">line</span>)
30:           <span class="ruby-keyword kw">when</span> <span class="ruby-regexp re">/^Story: /</span>           <span class="ruby-keyword kw">then</span> <span class="ruby-ivar">@state</span>.<span class="ruby-identifier">story</span>(<span class="ruby-identifier">line</span>)
31:           <span class="ruby-keyword kw">when</span> <span class="ruby-regexp re">/^Scenario: /</span>        <span class="ruby-keyword kw">then</span> <span class="ruby-ivar">@state</span>.<span class="ruby-identifier">scenario</span>(<span class="ruby-identifier">line</span>)
32:           <span class="ruby-keyword kw">when</span> <span class="ruby-regexp re">/^Given:? /</span>          <span class="ruby-keyword kw">then</span> <span class="ruby-ivar">@state</span>.<span class="ruby-identifier">given</span>(<span class="ruby-identifier">line</span>)
33:           <span class="ruby-keyword kw">when</span> <span class="ruby-regexp re">/^GivenScenario:? /</span>  <span class="ruby-keyword kw">then</span> <span class="ruby-ivar">@state</span>.<span class="ruby-identifier">given_scenario</span>(<span class="ruby-identifier">line</span>)
34:           <span class="ruby-keyword kw">when</span> <span class="ruby-regexp re">/^When:? /</span>           <span class="ruby-keyword kw">then</span> <span class="ruby-ivar">@state</span>.<span class="ruby-identifier">event</span>(<span class="ruby-identifier">line</span>)
35:           <span class="ruby-keyword kw">when</span> <span class="ruby-regexp re">/^Then:? /</span>           <span class="ruby-keyword kw">then</span> <span class="ruby-ivar">@state</span>.<span class="ruby-identifier">outcome</span>(<span class="ruby-identifier">line</span>)
36:           <span class="ruby-keyword kw">when</span> <span class="ruby-regexp re">/^And:? /</span>            <span class="ruby-keyword kw">then</span> <span class="ruby-ivar">@state</span>.<span class="ruby-identifier">one_more_of_the_same</span>(<span class="ruby-identifier">line</span>)
37:           <span class="ruby-keyword kw">else</span>                           <span class="ruby-ivar">@state</span>.<span class="ruby-identifier">other</span>(<span class="ruby-identifier">line</span>)
38:           <span class="ruby-keyword kw">end</span>
39:         <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000041" class="method-detail">
        <a name="M000041"></a>

        <div class="method-heading">
          <a href="#M000041" class="method-signature">
          <span class="method-name">states</span><span class="method-args">()</span>
          </a>
        </div>
      
        <div class="method-description">
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000041-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000041-source">
<pre>
    <span class="ruby-comment cmt"># File vendor/plugins/rspec/lib/spec/story/runner/story_parser.rb, line 85</span>
85:         <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">states</span>
86:           <span class="ruby-ivar">@states</span> <span class="ruby-operator">||=</span> {
87:             <span class="ruby-identifier">:starting_state</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-constant">StartingState</span>.<span class="ruby-identifier">new</span>(<span class="ruby-keyword kw">self</span>),
88:             <span class="ruby-identifier">:story_state</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-constant">StoryState</span>.<span class="ruby-identifier">new</span>(<span class="ruby-keyword kw">self</span>),
89:             <span class="ruby-identifier">:scenario_state</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-constant">ScenarioState</span>.<span class="ruby-identifier">new</span>(<span class="ruby-keyword kw">self</span>),
90:             <span class="ruby-identifier">:given_state</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-constant">GivenState</span>.<span class="ruby-identifier">new</span>(<span class="ruby-keyword kw">self</span>),
91:             <span class="ruby-identifier">:when_state</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-constant">WhenState</span>.<span class="ruby-identifier">new</span>(<span class="ruby-keyword kw">self</span>),
92:             <span class="ruby-identifier">:then_state</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-constant">ThenState</span>.<span class="ruby-identifier">new</span>(<span class="ruby-keyword kw">self</span>)
93:           }
94:         <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000040" class="method-detail">
        <a name="M000040"></a>

        <div class="method-heading">
          <a href="#M000040" class="method-signature">
          <span class="method-name">transition_to</span><span class="method-args">(key)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000040-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000040-source">
<pre>
    <span class="ruby-comment cmt"># File vendor/plugins/rspec/lib/spec/story/runner/story_parser.rb, line 81</span>
81:         <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">transition_to</span>(<span class="ruby-identifier">key</span>)
82:           <span class="ruby-ivar">@state</span> = <span class="ruby-identifier">states</span>[<span class="ruby-identifier">key</span>]
83:         <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>


    </div>


  </div>


<div id="validator-badges">
  <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
</div>

</body>
</html>